package edu.ybu.manage.config;

import edu.ybu.manage.interceptor.UserInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration  //表明是配置类
public class InterceptorConfig implements WebMvcConfigurer {

    // 所有的页面和请求
    private static final String[] all = {
            "/**/*.html",
            "/layuimini/**/*.html",
            "/captcha/**",
            "/course/**",
            "/exam/**",
            "/**",
            "/notice/**",
            "/score/**",
            "/student/**",
            "/teacher/**",
    };

    // 与登录和注册相关的界面和请求
    public static final String[] aboutLogin = {
            "/",
            "/layuimini/login.html",
            "/login"
    };


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInterceptor())
                .addPathPatterns(all).excludePathPatterns(aboutLogin);

    }
}
